/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.asiainfo.utils.sql.sqlbuilder.select;

import java.sql.SQLException;
import java.util.List;

public class Limit implements TerminalExpression {
	private final Context context;

	public Limit(Context context, int start, int size) {
		this.context = limit(context, start, size);
	}

	public <E> List<E> list(RowMapper<E> rowMapper) throws SQLException {
		return this.context.list(rowMapper);
	}

	public <E> E single(RowMapper<E> rowMapper) throws SQLException {
		return this.context.single(rowMapper);
	}

	private Context limit(Context context, int start, int size) {
		return new LimiterFactory().create(context.getDatabase()).limit(context, start, size);
	}
}